home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
cit.arc
/
LIBCRYP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1985-11-15
|
2KB
|
47 lines
/************************************************************************/
/* libCryp.c */
/* */
/* Library of encryption for Citadel */
/************************************************************************/
/************************************************************************/
/* history */
/* */
/* 85Nov15 HAW Created. */
/************************************************************************/
#include "ctdl.h"
/************************************************************************/
/* contents */
/* */
/* crypte() encrypts/decrypts data blocks */
/************************************************************************/
extern struct config cfg; /* Configuration variables */
/************************************************************************/
/* crypte() encrypts/decrypts data blocks */
/* */
/* This was at first using a full multiply/add pseudo-random sequence */
/* generator, but 8080s don't like to multiply. Slowed down I/O */
/* noticably. Rewrote for speed. */
/* 84Sep04 HAW I'll just use it...... */
/************************************************************************/
crypte(buf, len, seed)
unsigned char *buf;
unsigned len, seed;
{
static unsigned char *b; /* Make this static for speed (I guess),*/
static int c, s; /* since register variables not around */
seed = (seed + cfg.cryptSeed) & 0xFF;
b = buf;
c = len;
s = seed;
for (; c; c--) {
*b++ ^= s;
s = (s + CRYPTADD) & 0xFF;
}
}